debugger;

var wubi86 = [],
    wubi861 = [],
    pinyin = [],
    dazi_pk = [];
(function() {
    function fa(a) {
        return !1
    }

    function ga() {
        return !0
    }

    function v(a, b) {
        var e = b ? b : 0;
        if (a >= p.length) U();
        else {
            for (var c = 0; c < p.length; c += 2) {
                var d = p.item(c).getElementsByTagName("input").item(1);
                a == c && "stop" != e ? (d.readOnly = !1, d.onfocus = "", V(d), d.onkeydown = P, d.onkeyup = P, d.oninput = P, d.onclick = "") : "stop" != e ? d.onfocus = function() {
                    var b = p.item(a).getElementsByTagName("input").item(1);
                    V(b)
                } : (d.readOnly = !0, d.onkeydown = "", d.onkeyup = "", d.oninput = "", a == c && (d.onclick = function() {
                    confirm("\u6b63\u5904\u4e8e\u6682\u505c\u72b6\u6001\uff0c\u6062\u590d\u6253\u5b57\uff1f") && dazi_pause(G("pause_a"))
                }))
            }
            q = 0
        }
    }

    function P(a) {
        var b = a || window.event,
            e = this.parentNode.getElementsByTagName("div").item(0).getElementsByTagName("span").item(0),
            c = this.parentNode.getElementsByTagName("input").item(0);
        a = this.value.length;
        var d = c.value.length,
            g = L[f],
            ia = ha(c.value, this.value),
            b = b.which ? b.which : b.keyCode;
        e.innerHTML = ia;
        if (0 == W) 8 == b && 2 <= f && X != f - 2 && 1 != q && (q = 1, f -= 2, v(f), this.oninput = this.onkeyup = this.onkeydown = "", 150 > m(this) - z() && (u = m(this) - 150, window.scroll(0, u)));
        else {
            0 < a && 0 == r && Y();
            if (1 != q && f < p.length) {
                1 == A[f] - a && 0 == L[f] && 0 == g && Q++;
                if (a < d || " " != c.value.substring(d - 1, d)) A[f] = 0 < a ? a > d ? d : a : 0;
                e = R(A) - R(L);
                e - h > S && (S = e - h);
                h = e;
                B = R(Z)
            }
            d == a && c.value.substring(d - 1, d) == this.value.substring(a - 1, a) && A.length != f / 2 && 1 != q ? (q = 1, X = f, f += 2, setTimeout(function() {
                f < p.length && (p.item(f).getElementsByTagName("input").item(1).value = "");
                v(f)
            }, 10), this.oninput = this.onkeyup = this.onkeydown = "", 300 < m(this) - z() && (u = m(this) - 300, window.scroll(0, u))) : d < a && c.value.substring(d - 1, d) == this.value.substring(d - 1, d) && A.length != f / 2 && 1 != q ? (q = 1, c = this.value, p.item(f).getElementsByTagName("input").item(1).value = c.substr(0, d), f += 2, p.item(f).getElementsByTagName("input").item(1).value = c.substr(d, a - d), v(f), this.oninput = this.onkeyup = this.onkeydown = "", 300 < m(this) - z() && (u = m(this) - 300, window.scroll(0, u))) : d <= a && 13 == b && 1 != q && (q = 1, f += 2, v(f), this.oninput = this.onkeyup = this.onkeydown = "", 300 < m(this) - z() && (u = m(this) - 300, window.scroll(0, u)))
        }
        W = a
    }

    function Y() {
        0 == C && (C = w());
        clearTimeout(T);
        T = setTimeout(Y, 100);
        var a = G("typing_info_li"),
            b = G("name"),
            e = G("time"),
            c = 0 < D ? w() - D : 0;
        r = w() - C - c - aa;
        M = 0 < r ? E((h - B) / r * 6E4, 0) : 0;
        N = 0 < h ? E((h - B) / h * 100, 0) : 0;
        r > 5E3 * t.length && (1 <= t.length ? t[t.length] = h - ba : t[0] = h, ba = h);
        if ("undefined" != typeof dazi_pk[0]) {
            for (var c = .001 * r / 5, d = 0, g = 0; g < c + 1; g++) "undefined" != typeof dazi_pk[g] && (d = g == parseInt(c + 1) ? d + dazi_pk[g] * (c - parseInt(c)) : d + parseInt(dazi_pk[g]));
            F = d.toFixed(2);
            if (0 < F)
                for (var f = g = 0; f < p.length; f += 2) {
                    var n = p.item(f).getElementsByTagName("input").item(0),
                        c = p.item(f).getElementsByTagName("span").item(0),
                        d = p.item(f).getElementsByTagName("span").item(1),
                        n = n.value.length;
                    if (g + n > F) {
                        g = F - g;
                        g = g.toFixed(2);
                        d = d.offsetWidth;
                        c.style.display = "block";
                        c.style.left = parseInt(g / n * d) + "px";
                        c.className = F > h ? "dazi_pk" : "dazi_pk2";
                        break
                    } else g += parseInt(n), c.style.display = "none"
                }
        }
        b = '\x3cul\x3e\x3cli class\x3d"name"\x3e' + b.value + "\x3c/li\x3e\x3cli\x3e\u8bbe\u5b9a\uff1a" + e.value + ' \u5206\u949f\x3c/li\x3e\x3cli\x3e\x3cdiv id\x3d"time_table"\x3e';
        c = new Date(r);
        c = c.getMinutes() + "\u5206 " + c.getSeconds() + "\u79d2";
        a.innerHTML = b + c + "\x3c/div\x3e\x3c/li\x3e\x3cli\x3e\u901f\u5ea6\uff1a" + M + " " + ("cn" == G("type").value ? "WPM" : "KPM") + "\x3c/li\x3e\x3cli\x3e\u6b63\u786e\u7387\uff1a" + N + " %\x3c/li\x3e\x3c/ul\x3e\x3cli\x3e\u9519\u8bef\uff1a" + B + "\x3c/li\x3e\x3cli\x3e\u603b\u5b57\u6570\uff1a" + h + "\x3c/li\x3e\x3cli\x3e\u9000\u683c\uff1a" + Q + '\x3c/li\x3e\x3cli class\x3d"pinyin"\x3e\u62fc\u97f3\uff1a' + H + ("" != x ? "(" + x + ")" : "") + '\x3c/li\x3e\x3cli class\x3d"wubi86"\x3e\u4e94\u7b14\uff1a' + I + ("" != y ? "(" + y + ")" : "") + '\x3c/li\x3e\x3cli class\x3d"wubi86"\x3e\u8bcd\u7ec4\uff1a' + O + ("" != J ? "(" + J + ")" : "") + '\x3c/li\x3e\x3c/ul\x3e\x3cdiv class\x3d"clear"\x3e\x3c/div\x3e';
        b = r;
        a = G("time_table");
        c = G("time");
        b = E(b / (6E4 * parseInt(c.value)) * 100, 0) - 100;
        a.style.backgroundPosition = b + "px 0px";
        if (a = G("typing_info")) b = m(a) - z() - 100, c = window.innerHeight && window.scrollMaxY ? document.body.scrollWidth : document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollWidth : document.body.offsetWidth, a.style.marginRight = "0px", a.style.right = 124 < (c - 990) / 2 ? Math.round((c - 990) / 2 - 124) + "px" : "10px", 20 < b && (a.style.top = m(a) - E(.1 * Math.abs(b), 0) + "px"), 0 > b && (a.style.top = m(a) + E(.1 * Math.abs(b), 0) + "px");
        r >= 6E4 * e.value && (clearTimeout(T), U())
    }

    function U() {
        for (var a = qx1, b = 0, e = 0; e < t.length; e++) b += t[e];
        0 != h - b && (t[t.length] = h - b);
        document.getElementById(a).value = t.join(",");
        var c = tp1.split(",");
        if (7 == c.length) {
            var a = c[0],
                b = c[1],
                e = c[2],
                d = c[3],
                g = c[4],
                f = c[5],
                c = c[6];
            if (0 == ca) {
                ca = 1;
                var n = G("info_form");
                n.action += "?" + a + "\x3d" + S + "\x26" + b + "\x3d" + r + "\x26" + e + "\x3d" + M + "\x26" + d + "\x3d" + N + "\x26" + g + "\x3d" + Q + "\x26" + f + "\x3d" + h + "\x26" + c + "\x3d" + B;
                alert("\x3d\x3d\x3d\x3d\x3d\x3d\x3d\u6d4b\u8bd5\u7ed3\u679c\uff08" + ("cn" == G("type").value ? "\u4e2d\u6587" : "\u82f1\u6587") + "\u6253\u5b57\uff09\x3d\x3d\x3d\x3d\x3d\x3d\x3d\n\u65f6\u95f4\uff1a" + G("time").value + "\u5206\u949f\uff0c\u901f\u5ea6\uff1a" + M + ("cn" == G("type").value ? "WPM" : "KPM") + "\uff0c\u6b63\u786e\u7387\uff1a" + N + "%");
                n.submit()
            }
        }
    }

    function V(a) {
        if ("undefined" != typeof a.createTextRange) {
            var b = a.createTextRange();
            b.moveStart("character", a.value.length);
            b.collapse(!0);
            b.select()
        } else a.setSelectionRange(a.value.length, a.value.length), a.focus()
    }

    function ha(a, b) {
        str1 = da(a);
        str2 = da(b);
        var e = "",
            c = 0,
            d = null,
            g = 0,
            h = G("type").value,
            n = str1.length,
            k = str2.length;
        for (i = 0; i < (n > k ? n : k); i++)
            if (i < n) {
                var l = i < k ? b.substr(i) : null,
                    m = /^[a-z\' ]{1,20}$/;
                str1[i] == str2[i] ? e += '\x3cspan class\x3d"green"\x3e' + str1[i] + "\x3c/span\x3e" : null == str2[i] ? (e += str1[i], 0 == g && 0 < k && (g = i)) : "cn" == h && m.test(l) ? (e += '\x3cspan class\x3d"yellow"\x3e' + str1[i] + "\x3c/span\x3e", 0 == g && 0 < k && (g = i), null == d && (d = k < n ? k - i : n - i)) : (c++, e += '\x3cspan class\x3d"red"\x3e' + str1[i] + "\x3c/span\x3e")
            }
        if (0 == k || 0 != g) {
            h = p.item(f).id;
            h = h.substr(2);
            if ("array" == typeof wubi86[h] || "object" == typeof wubi86[h]) {
                if (k = wubi86[h], "array" == typeof k[g] || "object" == typeof k[g]) {
                    l = "";
                    for (m = g; m < g + k[g][0] && m < n; m++) l += str1[m];
                    J = l;
                    O = k[g][1]
                }
            } else J = "", O = "-";
            "array" == typeof wubi861[h] || "object" == typeof wubi861[h] ? (k = wubi861[h], "undefined" != typeof k[g] ? (y = str1[g], I = k[g]) : (y = "", I = "-")) : (y = "", I = "-");
            "array" == typeof pinyin[h] || "object" == typeof pinyin[h] ? (k = pinyin[h], "undefined" != typeof k[g] ? (x = str1[g], H = k[g]) : (x = "", H = "-")) : (x = "", H = "-")
        } else J = "", O = "-", x = "", H = "-", y = "", I = "-";
        Z[f] = c;
        L[f] = null == d ? 0 : d;
        return e
    }

    function R(a) {
        for (var b = 0, e = 0; e < 2 * a.length && e <= f; e += 2) 0 < a[e] && (b += a[e]);
        return b
    }

    function da(a) {
        for (var b = [], e = 0; e < a.length; e++) b[e] = a.substr(e, 1);
        return b
    }

    function w() {
        return (new Date).getTime()
    }

    function E(a, b) {
        return Math.round(a * Math.pow(10, b)) / Math.pow(10, b)
    }

    function z() {
        var a = 0;
        "undefined" != typeof window.pageYOffset ? a = window.pageYOffset : "undefined" != typeof window.document.compatMode && "BackCompat" != window.document.compatMode ? a = window.document.documentElement.scrollTop : "undefined" != typeof window.document.body && (a = window.document.body.scrollTop);
        return a
    }

    function m(a) {
        var b = a.offsetTop;
        for (a = a.offsetParent; null !== a;) b += a.offsetTop, a = a.offsetParent;
        return b
    }

    function ea(a) {
        a = a || window.event;
        var b = a.target || a.srcElement,
            e = b.type || b.getAttribute("type"),
            c = b.getAttribute("readonly"),
            b = b.getAttribute("enabled");
        if (8 == a.keyCode && "password" != e && "text" != e && "textarea" != e || !(8 != a.keyCode || "password" != e && "text" != e && "textarea" != e || 1 != (null == c ? !1 : c) && 1 == (null == b ? !0 : b))) return !1
    }
    var p = G("content").getElementsByTagName("div"),
        f = 0,
        C = 0,
        D = 0,
        aa = 0,
        A = [],
        Z = [],
        L = [],
        u = 0,
        X = -1,
        q = 0,
        t = [],
        ba = 0,
        O = "",
        J = "",
        I = "",
        y = "",
        H = "",
        x = "",
        F = 0,
        W = 0,
        M = 0,
        N = 0,
        r = 0,
        Q = 0,
        S = 0,
        h = 0,
        B = 0,
        K = null,
        ca = 0;
    window.onscroll = function() {
        window.scroll(0, u)
    };
    document.body.onpaste = function() {
        return !1
    };
    document.body.oncopy = function() {
        return !1
    };
    document.body.oncut = function() {
        return !1
    };
    document.onselectstart = new Function("return false");
    window.sidebar && (document.onmousedown = fa, document.onclick = ga);
    var T = null;
    dazi_pause = function(a) {
        "pause" == a.className ? (a.innerHTML = "\u7ee7\u7eed", a.className = "pause2", 0 < C && (D = w()), v(f, "stop")) : (a.innerHTML = "\u6682\u505c", a.className = "pause", 0 < C && (aa += w() - D, D = 0), v(f))
    };
    close_light = function(a) {
        "light" == a.className ? (a.innerHTML = "\u5f00\u706f", a.className = "light2", document.body.className = "dazi_style_black") : (a.innerHTML = "\u5173\u706f", a.className = "light", document.body.className = "")
    };
    var l = {
        o: null,
        init: function(a) {
            a.onmousedown = this.start
        },
        start: function(a) {
            a = l.fixEvent(a);
            a.preventDefault && a.preventDefault();
            l.o = this;
            this.x = a.clientX - l.o.offsetLeft;
            this.y = a.clientY - l.o.offsetTop;
            document.onmousemove = l.move;
            document.onmouseup = l.end
        },
        move: function(a) {
            a = l.fixEvent(a);
            var b;
            b = a.clientX - l.o.x;
            a = a.clientY - l.o.y;
            l.o.style.left = b + "px";
            l.o.style.top = a + "px"
        },
        end: function(a) {
            l.fixEvent(a);
            l.o = document.onmousemove = document.onmouseup = null
        },
        fixEvent: function(a) {
            a || (a = window.event, a.target = a.srcElement, a.layerX = a.offsetX, a.layerY = a.offsetY);
            return a
        }
    };
    typing_continue = function() {
        clearTimeout(K);
        K = setTimeout("typing_continue()", 31E5);
        var a = w(),
            b = new AjaxClass;
        b.Method = "GET";
        b.Url = "jingsai_do.php?do\x3dtyping_continue\x26start_page\x3d" + G("start_page").value + "\x26ssid\x3d" + G("ssid").value + "\x26t\x3d" + a;
        b.Async = !0;
        b.Loading = function() {};
        b.CallBack = function(a) {
            clearTimeout(K);
            K = setTimeout("typing_continue()", 3E6)
        };
        b.Send()
    };
    K = setTimeout("typing_continue()", 3E6);
    v(f);
    G("loading").style.display = "none";
    G("typing_info").style.display = "block";
    l.init(document.getElementById("typing_info"));
    document.onkeypress = ea;
    document.onkeydown = ea
})();




var customSpeed = 400;//你想要的速度(KPM, 最后结果可能会比这个值小一些)
var customDebounce = 60000/customSpeed;
var contentEle = document.getElementById('content');
var typeEles = document.getElementsByClassName('typing');
var myIndex = 0;
var ele = typeEles[myIndex];

var simulateKeyboardEvnet = function(keyCode, target){
		var keyboardEvent = document.createEvent("KeyboardEvent");
		var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? "initKeyboardEvent" : "initKeyEvent";


		keyboardEvent[initMethod](
                   "keydown", // event type : keydown, keyup, keypress
                    true, // bubbles
                    true, // cancelable
                    window, // viewArg: should be window
                    false, // ctrlKeyArg
                    false, // altKeyArg
                    false, // shiftKeyArg
                    false, // metaKeyArg
                    keyCode, // keyCodeArg : unsigned long the virtual key code, else 0
                    1 // charCodeArgs : unsigned long the Unicode character associated with the depressed key, else 0
		);
		target.dispatchEvent(keyboardEvent);
}

var autoInput = function(){
	var ele = typeEles[myIndex];
	if(ele.tagName == "DIV"){
		var words = ele.getElementsByTagName('DIV')[0].getElementsByTagName('SPAN')[0].innerHTML;
		var inputEle = ele.getElementsByTagName('input')[1];
		inputEle.focus();
		var wordIndex = 0;
		var interval = setInterval(function(){
			if(wordIndex == words.length-1){
				inputEle.value += ' ';
				simulateKeyboardEvnet(words.charCodeAt(' '), inputEle);
				myIndex += 2;
				clearInterval(interval);
				wordIndex = 0;
				autoInput();
				return;
			}
			inputEle.value += words[wordIndex];
			simulateKeyboardEvnet(words.charCodeAt(words[wordIndex]), inputEle);
		
			wordIndex ++;
		}, customDebounce)
	}
}

autoInput();




//中文版
debugger;
var customSpeed = 400;//你想要的速度(KPM, 最后结果可能会比这个值小一些)
var customDebounce = 60000/customSpeed;
var contentEle = document.getElementById('content');
var typeEles = document.getElementsByClassName('typing');
var myIndex = 0;
var ele = typeEles[myIndex];

var simulateKeyboardEvnet = function(keyCode, target){
		var keyboardEvent = document.createEvent("KeyboardEvent");
		var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? "initKeyboardEvent" : "initKeyEvent";


		keyboardEvent[initMethod](
                   "keydown", // event type : keydown, keyup, keypress
                    true, // bubbles
                    true, // cancelable
                    window, // viewArg: should be window
                    false, // ctrlKeyArg
                    false, // altKeyArg
                    false, // shiftKeyArg
                    false, // metaKeyArg
                    keyCode, // keyCodeArg : unsigned long the virtual key code, else 0
                    1 // charCodeArgs : unsigned long the Unicode character associated with the depressed key, else 0
		);
		target.dispatchEvent(keyboardEvent);
}

var autoInput = function(){
	var ele = typeEles[myIndex];
	if(ele.tagName == "DIV"){
		var words = ele.getElementsByTagName('DIV')[0].getElementsByTagName('SPAN')[0].innerHTML;
		var inputEle = ele.getElementsByTagName('input')[1];
		inputEle.focus();
		var wordIndex = 0;
		var interval = setInterval(function(){
			if(wordIndex == words.length){
				//inputEle.value += ' ';
				//simulateKeyboardEvnet(words.charCodeAt(' '), inputEle);
				myIndex += 3;
				clearInterval(interval);
				wordIndex = 0;
				autoInput();
				return;
			}
			inputEle.value += words[wordIndex];
			simulateKeyboardEvnet(words.charCodeAt(words[wordIndex]), inputEle);
		
			wordIndex ++;
		}, customDebounce)
	}
}

autoInput();